﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FoursquareNET.Checkins
{
    public class GetFriendCheckins
    {
        private const string URL = "http://api.foursquare.com/v1/checkins";
        private const Common.HttpRequestMethod HTTP_REQUEST_METHOD = Common.HttpRequestMethod.GET;
        
        private List<Parameter> Parameters = new List<Parameter>();

        /// <summary>
        /// Returns a list of recent checkins from friends.\n
        /// If you pass in a geolat/geolong pair (optional, but recommended), we'll send you back a distance inside each checkin object that you can use to sort your results.
        /// </summary>
        /// <param name="returnFormat"></param>
        public GetFriendCheckins()
        {
            
        }

        public List<Schema.Checkin> Execute(Credential credential)
        {
            Parameters.Clear();
            Parameters.Add(_Geolat);
            Parameters.Add(_Geolong);

            string result = Common.HTTPPost(URL, Parameters, credential, HTTP_REQUEST_METHOD);

            return new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<FoursquareNET.Schema.CheckinsObj>(result).Checkins;
        }

        #region Parameters

        private Parameter _Geolat = new Parameter("Geolat", "geolat", false);
        private Parameter _Geolong = new Parameter("Geolong", "geolong", false);

        /// <summary>
        /// (optional, but recommended)
        /// </summary>
        public double Geolat { set { _Geolat.Value = value.ToString(); } }

        /// <summary>
        /// (optional, but recommended)
        /// </summary>
        public double Geolong { set { _Geolong.Value = value.ToString(); } }

        #endregion
    }
}
